//
// Copyright © 2021 dev. All rights reserved.
// 

#import "CompositionalLayoutBackgroundSwizzler.h"
@import  Cocoa;
@import ConfUIFoundation;
#import "WWDCLearn-Swift.h"
#import <objc/runtime.h>
@implementation CompositionalLayoutBackgroundSwizzler
+(void)load{
    Method m  = class_getInstanceMethod(NSClassFromString("_NSScrollViewContentBackgroundView"), NSSelectorFromString(@"setBackgroundColor:"));
    if (!m) {
        return;
    }
    Method m2 = class_getInstanceMethod(NSClassFromString(@"OverrideNSScrollViewBackgroundView"), NSSelectorFromString(@"setBackgroundColor:"));
    if (!m2) {
        return;
    }
    class_addMethod(NSClassFromString(@"_NSScrollViewContentBackgroundView"), NSSelectorFromString(@"_original_setBackgroundColor:"), method_getImplementation(m), method_getTypeEncoding(m));
    method_exchangeImplementations(m, m2);
}
@end


@interface OverrideNSScrollViewBackgroundView : NSView
@end
@implementation OverrideNSScrollViewBackgroundView

- (void)setBackgroundColor:(NSColor *)color
{
    [self _original_setBackgroundColor:[NSColor contentBackground]];
}

- (void)_original_setBackgroundColor:(NSColor *)color
{

}

@end


